#!/bin/bash

# =================================================================
# INDIE VTUBER LAUNCHER (V4 COMPATIBLE)
# =================================================================

SCRIPT_NAME="vtuber_framework.py"

echo ">>> Checking System..."

# 1. Ensure Virtual Environment exists
if [ ! -d "venv" ]; then
    echo "[System] Virtual environment missing. Creating 'venv'..."
    python3 -m venv venv
fi

# 2. Ensure Dependencies are installed
# We run this every time to make sure numpy/pyaudio are present for the Physics Engine.
# It is very fast if they are already there.
echo "[System] Verifying libraries..."
./venv/bin/pip install rembg[cpu] pillow openai pyaudio pygame numpy tqdm sounddevice onnxruntime > /dev/null 2>&1

# 3. Check if the Python Framework exists
if [ ! -f "$SCRIPT_NAME" ]; then
    echo "[ERROR] $SCRIPT_NAME not found!"
    echo "Please make sure you pasted the V4 Python code into '$SCRIPT_NAME'."
    exit 1
fi

# 4. Launch
echo ">>> Launching V4 Physics Engine..."
echo "-----------------------------------"
./venv/bin/python "$SCRIPT_NAME"

